package com.micro.ai.files.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 文件附件实体类
 * 
 * @author micro-ai
 * @since 0.0.1
 */
@Data
@TableName("file_attachments")
@Schema(description = "文件附件信息")
public class FileAttachment implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Schema(description = "文件ID", example = "file_123456789")
    private String id;

    /**
     * 租户ID
     */
    @Schema(description = "租户ID", example = "tenant_001")
    private String tenantId;

    /**
     * 存储的文件名（系统中使用的文件名，可能包含路径）
     */
    @Schema(description = "存储文件名", example = "uploads/2025/01/abc123.jpg")
    private String filename;

    /**
     * 原始文件名（用户上传时的文件名）
     */
    @Schema(description = "原始文件名", example = "我的文档.jpg")
    private String originalName;

    /**
     * 文件路径（完整路径）
     */
    @Schema(description = "文件路径", example = "/data/files/uploads/2025/01/abc123.jpg")
    private String filePath;

    /**
     * 文件大小（字节）
     */
    @Schema(description = "文件大小（字节）", example = "1048576")
    private Long fileSize;

    /**
     * 文件哈希(SHA256)
     */
    @Schema(description = "文件哈希", example = "abc123...")
    private String fileHash;

    /**
     * MIME类型
     */
    @Schema(description = "MIME类型", example = "image/jpeg")
    private String mimeType;

    /**
     * 文件类型：image-图片, document-文档, audio-音频, video-视频, archive-压缩包, other-其他
     */
    @Schema(description = "文件类型", example = "image", allowableValues = {"image", "document", "audio", "video", "archive", "other"})
    private String fileType;

    /**
     * 音视频时长(秒)
     */
    @Schema(description = "音视频时长(秒)", example = "120")
    private Integer duration;

    /**
     * 图片/视频宽度
     */
    @Schema(description = "图片/视频宽度", example = "1920")
    private Integer width;

    /**
     * 图片/视频高度
     */
    @Schema(description = "图片/视频高度", example = "1080")
    private Integer height;

    /**
     * 缩略图路径
     */
    @Schema(description = "缩略图路径", example = "thumbnails/abc123_thumb.jpg")
    private String thumbnailPath;

    /**
     * 存储提供商：local-本地, s3-AWS S3, oss-阿里云OSS, cos-腾讯云COS, minio-MinIO
     */
    @Schema(description = "存储提供商", example = "minio", allowableValues = {"local", "s3", "oss", "cos", "minio"})
    private String storageProvider;

    /**
     * 存储配置ID
     */
    @Schema(description = "存储配置ID", example = "config_123")
    private String storageConfigId;

    /**
     * 所在文件夹ID
     */
    @Schema(description = "所在文件夹ID", example = "folder_123")
    private String folderId;

    /**
     * 关联类型（如：model_dataset, agent_avatar等）
     */
    @Schema(description = "关联类型", example = "model_dataset")
    private String associatedType;

    /**
     * 关联ID
     */
    @Schema(description = "关联ID", example = "dataset_123")
    private String associatedId;

    /**
     * 文件描述
     */
    @Schema(description = "文件描述", example = "这是一个测试文件")
    private String description;

    /**
     * 文件标签(JSON)
     */
    @Schema(description = "文件标签", example = "[\"标签1\", \"标签2\"]")
    private String tags;

    /**
     * 版本数量
     */
    @Schema(description = "版本数量", example = "1")
    private Integer versionCount;

    /**
     * 引用计数(用于去重)
     */
    @Schema(description = "引用计数", example = "1")
    private Integer referenceCount;

    /**
     * 是否公开（公开文件可以直接通过URL访问，无需认证）
     */
    @Schema(description = "是否公开", example = "false")
    private Boolean isPublic;

    /**
     * 删除时间
     */
    @Schema(description = "删除时间")
    private LocalDateTime deletedAt;

    /**
     * 删除人
     */
    @Schema(description = "删除人ID", example = "user_001")
    private String deletedBy;

    /**
     * 删除前原始路径
     */
    @Schema(description = "删除前原始路径", example = "/文档/我的文件.jpg")
    private String originalFolderPath;

    /**
     * 上传者ID
     */
    @Schema(description = "上传者ID", example = "user_001")
    private String uploaderId;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建时间", example = "2025-01-01 00:00:00")
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新时间", example = "2025-01-01 00:00:00")
    private LocalDateTime updatedAt;
}

